/*
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-05-19 10:07:19
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-05-21 18:59:40
 * @FilePath: /XMate-h5/src/services/badge/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { xmateHttp } from "../../utils/http";
import { BindDevice, ControlRecord } from "./type";

// 绑定设备
export const bindDeviceAPI = (data: BindDevice) => {
  return xmateHttp.request({
    url: `/rest/api/device/bind`,
    method: "POST",
    data,
    useOriginRes: true
  });
};

// 解除绑定
export const unBindDeviceAPI = () => {
  return xmateHttp.request({
    url: `/rest/api/device/unbind`,
    method: "PUT",
  });
};

// 开始/结束录音
export const controlRecordAPI = (data: ControlRecord) => {
  const { scheduleId } = data;
  let url = `/rest/api/device/record?cmdType=${data.cmdType}`;
  if (scheduleId) {
    url += `&scheduleId=${scheduleId}`;
  }
  return xmateHttp.request({
    url: url,
    method: "GET",
    timeout: 60000,
    useOriginRes: true
  });
}

// 结束普通的会议
export const endLiveConferenceAPI = (conferenceId: string, userId: string) => {
  return xmateHttp.request({
    url: `/rest/media/room/${conferenceId}`,
    method: "DELETE",
    data: {
      "operator": userId
    },
    useOriginRes: true
  })
}

// 获取进行中的沟通
export const getRecordingAPI = () => {
  return xmateHttp.request({
    url: `/rest/api/conference/ongoing`,
    method: "GET",
  })
}

// 获取设备信息
export const getDeviceInfoAPI = (snCode: string) => {
  return xmateHttp.request({
    url: `/rest/api/device/info`,
    method: "POST",
    disableProgress: true,
    data: {
      "snCodeList": [snCode]
    }
  })
}